package com.content.scaffold.common.config;

import com.content.scaffold.common.constants.PathPatternConstant;
import com.content.scaffold.common.interceptor.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 登录拦截器
 *
 * @author xiaojl
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Resource
    PathPatternConstant pathPatternConstant;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        InterceptorRegistration registration = registry.addInterceptor(loginInterceptor);
        registration.addPathPatterns(pathPatternConstant.getAddPath());
        registration.excludePathPatterns(pathPatternConstant.getExcludePath());

    }
}
